﻿using System.Threading.Tasks;
using Furion;
using Furion.DynamicApiController;
using GWB.Application.Common;
using GWB.Application.System.Auth.AuthService;
using GWB.Application.System.Auth.Dtos;
using GWB.Core;
using GWB.Core.Common.Entity;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace GWB.Application.System.Auth
{
    
    /// <summary>
    /// 
    /// </summary>
    [ApiDescriptionSettings("系统管理", Tag = "登录授权", SplitCamelCase = false)]
    public class AuthAppService: IDynamicApiController
    {
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [AllowAnonymous]
        [Authorization(Name ="登录")]
        public async Task<Result<AuthOutDto>> LoginAsync(AuthInputDto input)
        {
           return await  App.GetService<IAuthService>().LoginAsync(input);
        }

        /// <summary>
        /// 获取当前登录用户
        /// </summary>
        /// <returns></returns>
        [Authorization(Name = "获取当前登录用户")]
        public async Task<Result<CurrentUserDto>> GetCurrentUser()
        {
            return await App.GetService<IAuthService>().GetCurrentUser();
        }


        /// <summary>
        /// 健康检查
        /// </summary>
        /// <returns></returns>
        [ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify, Route("api/healthy")]
        public async Task<string> Get()
        {
            return "ok";
        }
    }
}
